<template>
  <div class="reconciliation-detail-box">
    <TitleBar
      title="对账统计详情"
      refresh
    />
    <div class="rec-detail-con">
      <div class="sale-msg">
        <div class="tit">订单信息</div>
        <ul>
          <li>
            <div class="th">订单编号</div>
            <div class="td">{{ orderMsg.order_code }}</div>
          </li>
          <li>
            <div class="th">第三方支付订单编号</div>
            <div class="td">{{ orderMsg.pay_code }}</div>
          </li>
          <li>
            <div class="th">订单金额</div>
            <div class="td">¥<span>{{ orderMsg.total_price }}</span></div>
          </li>
          <li>
            <div class="th">支付方式</div>
            <div class="td">{{ orderMsg.pay_type }}</div>
          </li>
          <li>
            <div class="th">支付时间</div>
            <div class="td">{{ orderMsg.pay_time }}</div>
          </li>
          <li>
            <div class="th">订单状态</div>
            <div class="td">{{ orderMsg.order_state }}</div>
          </li>
        </ul>
      </div>
      <reconciliation
        v-if="table.check_type===PASS_DATA[0].name"
        :data="table"
      />
      <no-reconciliation
        v-if="table.check_type===PASS_DATA[1].name"
        :data="table"
      />
      <abnormal
        v-if="table.check_type===PASS_DATA[2].name"
        :data="table"
        @passInp="passInp"
      />
      <correct
        v-if="table.check_type===PASS_DATA[3].name"
        :data="table"
      />
    </div>
    <div
      v-if="table.check_type===PASS_DATA[2].name"
      class="abnormal"
      @click="abnormalBtn"
    >冲正处理</div>
  </div>
</template>

<script>
import reconciliation from '../comptents/reconciliation'
import noReconciliation from '../comptents/nonReconciliation'
import correct from '../comptents/correct'
import abnormal from '../comptents/abnormal'
import { constants } from 'crypto'
import { formatDateAndTime } from '@/utils/util.js'
import { ORDER_STATUS, PAY_TYPE, PASS_DATA } from '@/utils/enum.js'
import { getdetailList, getUpdate } from '@/api/capital.js'
export default {
  components: {
    reconciliation,
    noReconciliation,
    correct,
    abnormal
  },

  data() {
    return {
      PASS_DATA,
      table: {
        // status: "异常",
        // name: "张明",
        // time: "2019-07-19 14:48:38",
        // remarks: "无"
      },
      input: '',
      title: '',
      orderMsg: [],
      checkType: null
    }
  },
  created() {
    console.log()
    this.getData()
  },
  methods: {
    getData() {
      console.log(this.$route.query.code)
      getdetailList({
        orderCode: this.$route.query.code
      }).then(res => {
        console.log(res)
        this.title = PASS_DATA.getName(res.data[0].check_type)
        res.data[0].order_state = ORDER_STATUS.getName(res.data[0].order_state)
        res.data[0].pay_type = PAY_TYPE.getName(res.data[0].pay_type)
        res.data[0].check_type = PASS_DATA.getName(res.data[0].check_type)

        if (res.data[0].pay_time) {
          res.data[0].pay_time = formatDateAndTime(res.data[0].pay_time)
        } else {
          res.data[0].pay_time = '/'
        }
        if (res.data[0].create_time) {
          res.data[0].create_time = formatDateAndTime(res.data[0].create_time)
        } else {
          res.data[0].create_time = '/'
        }
        this.orderMsg = res.data[0]
        this.table = res.data[0]
      })
    },
    // 返回
    reTurn() {
      this.$router.push({
        name: 'reconciliationList'
      })
    },
    //
    passInp(inp) {
      this.input = inp
    },
    // 冲正处理
    abnormalBtn() {
      console.log(this.input)
      getUpdate({
        accountCheck: {
          id: this.$route.query.code,
          remarks: this.input
        }
      })
        .then(res => {
          console.log(res)
        })
        .catch(res => {
          console.log(res)
        })
    }
  }
}
</script>
